#include<iostream>
#include<sys/types.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<unistd.h>
#include<string.h>
using namespace std;
#define FIFO "./.pipe"
int main()
{
  int fd=open(FIFO,O_WRONLY);
  if(fd<0)
  {
    cout<<"open fail"<<endl;
    return -1;
  }

  char buffer[64];
  while(1)
  {
    buffer[0]=0;
    cout<<"#please enter#"<<endl;
    ssize_t s=read(0,buffer,sizeof(buffer)-1);
    if(s>0)
    {

      buffer[s]=0;
      write(fd,buffer,strlen(buffer));
    }
    if(s==0)
    {
      cout<<"write end"<<endl;
      return 0;
    }
  }
  return 0;
}
